export default {
	// 获取页面数据
	getTableData() {
		var params = {
			language: this.$store.getters.getLanguage,
		}

		this.axiosPost("Development/pipelineIndexShow", params, function(res) {
			// console.log(res);
			if(res.data.code === 0) {
				this.tableData = res.data.data
				this.tableData.pli_0.value = JSON.parse(this.tableData.pli_0.value);
				this.tableData.pli_1.value = JSON.parse(this.tableData.pli_1.value);
				this.tableData.pli_2.value = JSON.parse(this.tableData.pli_2.value);
				this.tableData.pli_3.value = JSON.parse(this.tableData.pli_3.value);
				this.tableData.pli_4.value = JSON.parse(this.tableData.pli_4.value);
				
				let url = this.tableData.pli_4.value.content;
				console.log(url);
				this.fileList = [{name:url.substring(url.lastIndexOf('/')+1),file:this.tableData.pli_4.value}]
				// this.msgSuccess(res.data.message)
			} else  {
				this.msgError(res.data.message)
			}
			//分页
			// this.total = res.data.data.total
			// console.log(this.total);
		})
	},
	
	

	//编辑
	edit(val) {
		this.$refs.Edit.key = val;
		this.$refs.Edit.form = this.tableData[val].value;
		this.$refs.Edit.upImg.imageUrl = this.tableData[val].value.img_url;
		this.$refs.Edit.isShow = true;
	},
	
	editContent(val) {
		this.key1 = val;
		// this.c = c;
		this.form = this.tableData[val].value;
		this.isShow1 = true;
	},
	
	
	editFile(val) {
		this.key1 = val;
		// this.c = c;
		this.form = this.tableData[val].value;
		this.isShow2 = true;
	},
	
	submit(){
		let params = {
			key : this.key1,
			value : JSON.stringify(this.form),
			language:this.$store.getters.getLanguage
		}
		console.log(params);
		this.axiosPost('Development/pipelineIndex', params , res => {
			if(res.data.code === 0) {
				this.msgSuccess(res.data.message);
				this.getTableData();
				this.isShow1 = false;
			}else {
				this.msgError(res.data.message)
			}
		})
	},
	//图片上传
	handleAvatarSuccess(res,file) {
		console.log(res, file);
		this.msgSuccess(res.message)
		this.upImg.file = file.raw;
		this.upImg.imageUrl = res.data;
		
		this.fileList = [{name:file.name,file:file.raw}]
		
		this.key1 = 'pli_4';
		this.form.content = res.data;
		
		this.submit();
	},
	
	
	
	
	closeDialog(){
		this.key1 = '',//key
		this.form = {//form
			content:''
		}
		this.isShow1 = false;
	},
	
	
	closeDialog1(){
		this.isShow2 = false;
	},

	
}
